package com.wn.icloud.common.utils;

import java.text.NumberFormat;
import java.util.regex.Pattern;

/**
 * @Description TODO
 * @Author WTL
 * @Date 2019/6/10
 **/
public class NumFormatUtil {

    public static String toPercent(int num1, int num2) {
        NumberFormat numberFormat = NumberFormat.getInstance();
        numberFormat.setMaximumFractionDigits(2);
        return numberFormat.format((float) num1 / (float) num2 * 100) + "%";
    }

    /**
     * java判断是否是整数
     * @param str
     * @return 是整数返回true,否则返回false
     */
    public static boolean isInteger(String str) {
        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
        return pattern.matcher(str).matches();
    }
}
